package juego;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class JuegoServlet {

	public void doGet(HttpServletRequest _request, HttpServletResponse _response) throws ServletException, IOException {
		String codigoPartida = _request.getParameter("id");
		String bando = _request.getParameter("b");
		HttpSession session = _request.getSession();
		synchronized (session) {
			session.setAttribute("codigoPartida", codigoPartida);
			session.setAttribute("bando", bando);
		}
		
		RequestDispatcher reqDisp  = _request.getRequestDispatcher("juego.jsp");
		reqDisp.forward(_request, _response);
	}
	
	public void doPost(HttpServletRequest _request, HttpServletResponse _response) throws ServletException, IOException	{
		HttpSession session = _request.getSession();
		RequestDispatcher rd;
		synchronized (session) {
			session.setAttribute("error", "No se aceptan peticiones por POST");
		}
		rd = _request.getRequestDispatcher("error.jsp");
		rd.forward(_request, _response);
	}
	
	
}
